package com.goodving.guli.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.C0708b;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.view.C4220a;

import java.util.Locale;

/**
 * Created by john on 2015/11/26.
 */
public class MultiDevicesErrActivity extends SystemBarTintActivity implements OnClickListener {
    private static final String f3639a = "MultiBraceletErrActivity";
    private String f3640b;
    private TextView f3641c;
    private TextView f3642d;
    private Button f3643e;
    private Button f3644f;
    private Context f3645g;

    public MultiDevicesErrActivity() {
        this.f3645g = this;
    }

    private boolean m8199a() {
        return Utils.f3495c.equals(this.f3640b) || Utils.f3496d.equals(this.f3640b);
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 6 && i2 == -1) {
            GuliLog.tracePrintInfo(f3639a, "onActivityResult, result OK, finish");
            finish();
        }
    }

    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()) {
            case R.id.donot_bind_txt:
                Keeper.keepNeedBind(0);
                intent.setClass(this, MainFragmentActivity.class);
                startActivity(intent);
                finish();
                if (Utils.f3494b.equals(this.f3640b)) {
//                    C0668a.m8129a((Context) this, C0708b.f3707V, C0715c.f3772n, Constants.VIA_SSO_LOGIN);
                } else {
//                    C0668a.m8129a((Context) this, C0708b.an, C0715c.f3772n, Constants.VIA_SSO_LOGIN);
//                    C0668a.m8128a(this.f3645g, C0668a.ga, C0668a.gd);
                }
//                C0668a.m8126a((Context) this, C0668a.dI);
                break;
            case R.id.buy_bracelet_stuff:
//                C0891d.m9079a((Activity) this, false);
//                C0668a.m8126a(this.f3645g, C0708b.ad);
//                C0668a.m8128a(getApplicationContext(), C0668a.be, C0668a.cd);
                break;
            case R.id.multi_devices_err_help_btn:
//                intent = new Intent(this, HelpActivity.class);
//                intent.putExtra(Utils.f3493a, this.f3640b);
//                startActivity(intent);
//                C0668a.m8128a(this.f3645g, C0668a.gb, C0668a.gd);
                break;
            case R.id.multi_devices_err_device_list_btn:
                intent.putExtra(C4220a.bz, true);
                if (Utils.f3494b.equals(this.f3640b)) {
                    intent.setClass(this, SearchSingleBraceletActivity.class);
                    C0668a.m8126a(this.f3645g, C0708b.ac);
                } else if (Utils.f3495c.equals(this.f3640b)) {
                    intent.setClass(this, SearchWeightScaleActivity.class);
                }
                startActivityForResult(intent, 6);
                C0668a.m8126a((Context) this, C0668a.dJ);
                break;
            case R.id.multi_devices_err_search_again:
                intent.setClass(this, SearchSingleBraceletActivity.class);
                intent.putExtra(C4220a.bz, false);
                if (Utils.f3494b.equals(this.f3640b)) {
                    intent.setClass(this, SearchSingleBraceletActivity.class);
                    C0668a.m8126a(this.f3645g, C0708b.ab);
                } else if (m8199a()) {
                    intent.setClass(this, SearchWeightScaleActivity.class);
                    C0668a.m8128a(this.f3645g, C0668a.fZ, C0668a.gd);
                }
                startActivity(intent);
                finish();
                break;
            default:
        }
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.multi_devices_err);
        Intent intent = getIntent();
        if (intent != null) {
            this.f3640b = intent.getStringExtra(Utils.f3493a);
            int intExtra = intent.getIntExtra(SearchSingleBraceletActivity.f9148a, -1);
            GuliLog.tracePrintInfo(f3639a, "infoResId " + intExtra);
            if (intExtra > 0) {
                ((TextView) findViewById(R.id.multi_devices_info)).setText(intExtra);
            }
        }
//        LinePieChartView linePieChartView = (LinePieChartView) findViewById(R.id.searching_pie_chart);
        findViewById(R.id.multi_devices_err_search_again).setOnClickListener(this);
        this.f3643e = (Button) findViewById(R.id.multi_devices_err_device_list_btn);
        this.f3643e.setOnClickListener(this);
        this.f3644f = (Button) findViewById(R.id.multi_devices_err_help_btn);
        this.f3644f.setOnClickListener(this);
        View findViewById = findViewById(R.id.buy_bracelet_stuff);
        findViewById.setOnClickListener(this);
        TextView textView = (TextView) findViewById(R.id.donot_bind_txt);
        textView.setText(Html.fromHtml("<u>" + getString(R.string.donot_bind) + "</u>"));
        textView.setOnClickListener(this);
//        if (Config.m8876h().f4198h.f4242a.booleanValue()) {
//            findViewById.setVisibility(View.VISIBLE);
//        } else {
//            findViewById.setVisibility(View.GONE);
//        }
        this.f3641c = (TextView) findViewById(R.id.multi_devices_err_title);
        this.f3642d = (TextView) findViewById(R.id.multi_devices_info);
        if (Utils.f3494b.equals(this.f3640b)) {
            this.f3641c.setText(R.string.multi_devices_title);
            this.f3642d.setText(R.string.multi_devices_info);
            this.f3643e.setText(R.string.look_device_list);
//            linePieChartView.setMode(0);
            if (Locale.getDefault().toString().equals(Locale.SIMPLIFIED_CHINESE.toString())) {
                findViewById.setVisibility(View.VISIBLE);
            } else {
                findViewById.setVisibility(View.GONE);
            }
            this.f3644f.setVisibility(View.GONE);
        } else if (m8199a()) {
            this.f3641c.setText(R.string.multi_devices_weight_title);
            this.f3642d.setText(R.string.multi_weight_devices_info);
            this.f3643e.setText(R.string.look_weight_device_list);
            this.f3643e.setVisibility(View.GONE);
//            linePieChartView.setMode(3);
            findViewById.setVisibility(View.GONE);
            this.f3644f.setVisibility(View.VISIBLE);
        }
    }

    protected void onPause() {
        super.onPause();
//        C0668a.m8141b(C0668a.f3579v);
//        C0668a.m8138b((Activity) this);
    }

    protected void onResume() {
        super.onResume();
//        C0668a.m8133a(C0668a.f3579v);
//        C0668a.m8124a((Activity) this);
    }
}
